﻿#region MIT License
/*

Copyright (C) 2011 by Timothy A. Barela

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

*/
#endregion

using System;
using System.Diagnostics;
using System.Collections.Generic;
using LineCommander;

namespace Sharpener
{
	public class SharpenerCommandLine : CommandLine
	{
		[Option(LongName="quiet",ShortNames="q",Help="Shuts Sharpener Up.")]
		public bool Quiet { get; set; }

		[Option(LongName="out",ShortNames="o",Help="Sets the output file name.")]
		public string Out { get; set; }

		[Option(LongName="all",ShortNames="a",Help="Enables all transformations.")]
		public bool All { get; set; }

		[Option(LongName="stripcallvirt",Help="Attempts to replace callvirt's with call instructions.")]  
		public bool StripCallVirt { get; set; }

		[Option(LongName="forceinline",Help="Inlines methods marked with the ForceInline attribute.")]
		public bool ForceInline { get; set; }

		[Option(LongName="operatorinline",Help="Not implemented yet. Sorry.")]
		public bool InlineValueTypeOperators { get; set; }

		//[Option(LongName = "boo-tweaks",Help = "Not implemented yet. Sorry.")]
		//public bool BooTweaks { get; set; }

		[Option(LongName="watermark",Help="Marks the assembly with a Sharpened attribute.")]
		public bool Watermark { get; set; }
		
		public SharpenerCommandLine()
		{
			Configuration = CommandLineConfiguration.CreateUnixStyle();
		}

		public void Print(string msg)
		{
			if(!Quiet)
				Console.WriteLine(msg);
		}

		public void Print(string format,params object[] args)
		{
			if(!Quiet)
				Console.WriteLine(format,args);
		}

		public override string GetHeadingString()
		{
			var sb = new System.Text.StringBuilder();
			var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

			sb.AppendFormat("Sharpener - An assembly optimizer for the CLR, version {0}\n",version);
			sb.AppendLine("By Timothy A. Barela (https://bitbucket.org/tbarela/sharpener)");
						
			return sb.ToString();
		}

		public override string GetUsageString()
		{
			return "Usage is: sharpener [options] filename";
		}
	}
}